class Solution {
public:
    bool detectCapitalUse(string word) {
        if (word[0] >= 'A' && word[0] <= 'Z')
        {
            int cnt = 0;
            for (int i = 0; i < word.size(); i++)
                if (word[i] >= 'A' && word[i] <= 'Z') cnt++;
            if (cnt == 1 || cnt == word.size()) return true;
            else return false;
        }
        else
        {
            for (int i = 1; i < word.size(); i++)
                if (word[i] >= 'A' && word[i] <= 'Z') return false;
        }
        return true;
    }
};